/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.core.repository.mapper;

import info.peigen.hotpot.business.router.core.repository.entity.RouterWithdrawEntity;
import info.peigen.hotpot.business.router.facade.enums.WithdrawStatus;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

/**
 * <b>(RouterWithdrawMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
public interface RouterWithdrawMapper extends AbstractBeetlSqlMapper<RouterWithdrawEntity> {
    @Sql("select * from router_withdraw where withdraw_id = ?")
    @Select
    RouterWithdrawEntity findByWithdrawId(String withdrawId);

    @Sql("select * from router_withdraw where trade_id = ?")
    @Select
    RouterWithdrawEntity findByTradeId(String tradeId);

    @Sql("select * from router_withdraw where batch_no = ?")
    @Select
    RouterWithdrawEntity findByBatchNo(String batchNo);

    @Sql("select * from router_withdraw where channel_uni_id = ?")
    @Select
    RouterWithdrawEntity findByChannelUniId(String channelUniId);

    @Sql("select * from router_withdraw where id=(select max(id) from router_withdraw where status = ?)")
    @Select
    RouterWithdrawEntity findLastByStatus(WithdrawStatus status);

    @Sql("delete from router_withdraw where withdraw_id = ?")
    @Update
    void deleteByWithdrawId(String withdrawId);

    @Sql("delete from router_withdraw where trade_id = ?")
    @Update
    void deleteByTradeId(String tradeId);

    @Sql("delete from router_withdraw where batch_no = ?")
    @Update
    void deleteByBatchNo(String batchNo);
}